package com.hyou.demos.mybatis.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.hyou.demos.mybatis.base.BaseService;
import com.hyou.demos.mybatis.dao.DemoUserDao;
import com.hyou.demos.mybatis.pojo.DemoUser;
import com.hyou.demos.mybatis.service.DemoUserService;

@Service("demoUserService")
public class DemoUserServiceImpl extends BaseService implements DemoUserService {
    
    private static final Logger log = LoggerFactory.getLogger(DemoUserServiceImpl.class);
    
    @Override
    public void insert(DemoUser param) {
        log.debug("param=[{}]", param);
        getWriteMapper(DemoUserDao.class).insert(param);
    }
    
    @Override
    public void updateByPKSelective(DemoUser param) {
        getWriteMapper(DemoUserDao.class).updateByPKSelective(param);
    }
    
    @Override
    public DemoUser selectByPK(Long id) {
        return getReadMapper(DemoUserDao.class).selectByPK(id);
    }
    
    @Override
    public List<DemoUser> selectByConditions(DemoUser param) {
        return getReadMapper(DemoUserDao.class).selectByConditions(param);
    }
    
    @Override
    public List<DemoUser> selectByPage(DemoUser param, int offset, int limit) {
        PageHelper.offsetPage(offset, limit);
        return getReadMapper(DemoUserDao.class).selectByConditions(param);
    }
    
    @Override
    public void transTest(DemoUser insertParam, DemoUser updParam) {
        updateByPKSelective(updParam);
        insert(insertParam);
    }
    
}
